package com.javacode2018.lesson001.demo18;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 综合案例
 */
@Target(value = {
        ElementType.TYPE,
        ElementType.METHOD,
        ElementType.FIELD,
        ElementType.PARAMETER,
        ElementType.CONSTRUCTOR,
        ElementType.LOCAL_VARIABLE
})
@Retention(RetentionPolicy.RUNTIME)
@interface Ann6 {
    String value();

    ElementType elementType();
}

@Ann6(value = "我在类上", elementType = ElementType.TYPE)
public class UserAnnotation6 {
    @Ann6(value = "我在字段上", elementType = ElementType.FIELD)
    public String a;

    @Ann6(value = "我在构造方法上", elementType = ElementType.CONSTRUCTOR)
    public UserAnnotation6(@Ann6(value = "我在方法参数上", elementType = ElementType.PARAMETER)String a){
        this.a = a;
    }

    @Ann6(value = "我在普通方法上", elementType = ElementType.METHOD)
    public void m1(){
        @Ann6(value = "我在本地变量上", elementType = ElementType.LOCAL_VARIABLE)String a;
    }
}
